<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from /home/jaffer/scheme/r5rs.txi on 28 March 2001 -->

<TITLE>Revised(5) Scheme - 2. Lexical conventions</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="r5rs_1.html">first</A>, <A HREF="r5rs_3.html">previous</A>, <A HREF="r5rs_5.html">next</A>, <A HREF="r5rs_14.html">last</A> section, <A HREF="r5rs_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC14" HREF="r5rs_toc.html#TOC14">2. Lexical conventions</A></H1>

<P>
<A NAME="IDX28"></A>


<P>
This section gives an informal account of some of the lexical
conventions used in writing Scheme programs.  For a formal syntax of
Scheme, see section <A HREF="r5rs_9.html#SEC72">7.1 Formal syntax</A>.


<P>
Upper and lower case forms of a letter are never distinguished
except within character and string constants.  For example, <SAMP>`Foo'</SAMP> is
the same identifier as <SAMP>`FOO'</SAMP>, and <TT>#x1AB</TT> is the same number as
<TT>#X1ab</TT>.




<H2><A NAME="SEC15" HREF="r5rs_toc.html#TOC15">2.1 Identifiers</A></H2>

<P>
<A NAME="IDX29"></A>


<P>
Most identifiers allowed by other programming
<A NAME="IDX30"></A>
languages are also acceptable to Scheme.  The precise rules for forming
identifiers vary among implementations of Scheme, but in all
implementations a sequence of letters, digits, and "extended alphabetic
characters" that begins with a character that cannot begin a number is
an identifier.  In addition, <CODE>+</CODE>, <CODE>-</CODE>, and <CODE>...</CODE> are identifiers. 
<A NAME="IDX31"></A>
<A NAME="IDX32"></A>
<A NAME="IDX33"></A>
Here are some examples of identifiers:



<PRE>

lambda                   q
list-&#62;vector             soup
+                        V17a
&#60;=?                      a34kTMNs
the-word-recursion-has-many-meanings

</PRE>

<P>
Extended alphabetic characters may be used within identifiers as if
they were letters.  The following are extended alphabetic characters:



<PRE>

! $ % &#38; * + - . / : &#60; = &#62; ? @ ^ _ ~ 
</PRE>

<P>
See section <A HREF="r5rs_9.html#SEC73">7.1.1 Lexical structure</A> for a formal syntax of identifiers.


<P>
Identifiers have two uses within Scheme programs:



<UL>

<LI>

Any identifier may be used as a variable
or as a syntactic keyword
(see sections see section <A HREF="r5rs_5.html#SEC19">3.1 Variables; syntactic keywords; and regions</A> and see section <A HREF="r5rs_6.html#SEC39">4.3 Macros</A>).

<LI>

When an identifier appears as a literal or within a literal
(see section see section <A HREF="r5rs_6.html#SEC27">4.1.2 Literal expressions</A>), it is being used to denote a <EM>symbol</EM>
(see section see section <A HREF="r5rs_8.html#SEC60">6.3.3 Symbols</A>).

</UL>

<P>
<A NAME="IDX34"></A>
<A NAME="IDX35"></A>




<H2><A NAME="SEC16" HREF="r5rs_toc.html#TOC16">2.2 Whitespace and comments</A></H2>

<P>
<A NAME="IDX36"></A>


<P>
<EM>Whitespace</EM> characters are spaces and newlines.
<A NAME="IDX37"></A>
(Implementations typically provide additional whitespace characters such
as tab or page break.)  Whitespace is used for improved readability and
as necessary to separate tokens from each other, a token being an
indivisible lexical unit such as an identifier or number, but is
otherwise insignificant.  Whitespace may occur between any two tokens,
but not within a token.  Whitespace may also occur inside a string,
where it is significant.


<P>
A semicolon (<TT>;</TT>) indicates the start of a
comment.  The comment continues to the
<A NAME="IDX38"></A>
<A NAME="IDX39"></A>
end of the line on which the semicolon appears.  Comments are invisible
to Scheme, but the end of the line is visible as whitespace.  This
prevents a comment from appearing in the middle of an identifier or
number.



<PRE>

;;; The FACT procedure computes the factorial
;;; of a non-negative integer.
(define fact
  (lambda (n)
    (if (= n 0)
        1        ;Base case: return 1
        (* n (fact (- n 1))))))

</PRE>



<H2><A NAME="SEC17" HREF="r5rs_toc.html#TOC17">2.3 Other notations</A></H2>

<P>
<A NAME="IDX40"></A>


<P>
For a description of the notations used for numbers, see
section <A HREF="r5rs_8.html#SEC50">6.2 Numbers</A>.


<DL COMPACT>

<DT><TT><TT>. + -</TT></TT>
<DD>
These are used in numbers, and may also occur anywhere in an identifier
except as the first character.  A delimited plus or minus sign by itself
is also an identifier.
A delimited period (not occurring within a number or identifier) is used
in the notation for pairs (section see section <A HREF="r5rs_8.html#SEC59">6.3.2 Pairs and lists</A>), and to indicate a
rest-parameter in a  formal parameter list (section see section <A HREF="r5rs_6.html#SEC29">4.1.4 Procedures</A>).
A delimited sequence of three successive periods is also an identifier.

<DT><TT><TT>( )</TT></TT>
<DD>
Parentheses are used for grouping and to notate lists
(section see section <A HREF="r5rs_8.html#SEC59">6.3.2 Pairs and lists</A>).

<DT><TT><TT>'</TT></TT>
<DD>
The single quote character is used to indicate literal data (section see section <A HREF="r5rs_6.html#SEC27">4.1.2 Literal expressions</A>).

<DT><TT><TT>`</TT></TT>
<DD>
The backquote character is used to indicate almost-constant
data (section see section <A HREF="r5rs_6.html#SEC38">4.2.6 Quasiquotation</A>).

<DT><TT><TT>, ,@</TT></TT>
<DD>
The character comma and the sequence comma at-sign are used in conjunction
with backquote (section see section <A HREF="r5rs_6.html#SEC38">4.2.6 Quasiquotation</A>).

<DT><TT><TT>"</TT></TT>
<DD>
The double quote character is used to delimit strings (section see section <A HREF="r5rs_8.html#SEC62">6.3.5 Strings</A>).

<DT><TT>\</TT>
<DD>
Backslash is used in the syntax for character constants
(section see section <A HREF="r5rs_8.html#SEC61">6.3.4 Characters</A>) and as an escape character within string
constants (section see section <A HREF="r5rs_8.html#SEC62">6.3.5 Strings</A>).

<DT><TT><TT>[ ] { } |</TT></TT>
<DD>
Left and right square brackets and curly braces and vertical bar
are reserved for possible future extensions to the language.

<DT><TT>#</TT>
<DD>
 Sharp sign is used for a variety of purposes depending on
the character that immediately follows it:

<DT><TT><TT>#t</TT> <TT>#f</TT></TT>
<DD>
These are the boolean constants (section see section <A HREF="r5rs_8.html#SEC58">6.3.1 Booleans</A>).

<DT><TT>#\</TT>
<DD>
This introduces a character constant (section see section <A HREF="r5rs_8.html#SEC61">6.3.4 Characters</A>).

<DT><TT>#<TT>(</TT></TT>
<DD>
This introduces a vector constant (section see section <A HREF="r5rs_8.html#SEC63">6.3.6 Vectors</A>).  Vector constants
are terminated by <TT>)</TT> .

<DT><TT><TT>#e #i #b #o #d #x</TT></TT>
<DD>
These are used in the notation for numbers (section see section <A HREF="r5rs_8.html#SEC54">6.2.4 Syntax of numerical constants</A>).

</DL>

<P>
       


<P><HR><P>
Go to the <A HREF="r5rs_1.html">first</A>, <A HREF="r5rs_3.html">previous</A>, <A HREF="r5rs_5.html">next</A>, <A HREF="r5rs_14.html">last</A> section, <A HREF="r5rs_toc.html">table of contents</A>.
</BODY>
</HTML>
